import {
  ArticlePageParam,
  TagPageParam,
  CategoryPageParam,
  CommentPageParam,
  SignEventPageParam,
  SignAttendancePageParam,
  SignPointPageParam,
  CategoryAddParam,
  CommentAddParam,
  TagAddParam,
  SignAttendanceAddParam,
  SignEventAddParam,
  SignPointAddParam,
  TagUpdatedParam,
  CategoryUpdatedParam,
  CommentUpdatedParam,
  SignAttendanceUpdatedParam,
  SignEventUpdatedParam,
  SignPointUpdatedParam,
  ArticleListGetResultModel,
  TagPageListGetResultModel,
  CategoryPageListGetResultModel,
  SignEventPageListGetResultModel,
  SignAttendancePageListGetResultModel,
  SignPointPageListGetResultModel
} from './model/bbsModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  article = '/plugins/baliServer-module-article/api/article',
  tag = '/plugins/baliServer-module-article/api/tag',
  category = '/plugins/baliServer-module-article/api/category',
  comment = '/plugins/baliServer-module-article/api/comment',
  signAttendance = '/plugins/baliServer-module-sign/api/sign/attendance',
  signEvent = '/plugins/baliServer-module-sign/api/sign/event',
  signPoint = '/plugins/baliServer-module-sign/api/sign/point',
  activeUser = '/plugins/baliServer-module-active-user/api/activeuser',
  personInforamtion = '/plugins/baliServer-module-person-information+/api/personInformation',
}

/**
 * 文章
 */
export const getPostList = (params: ArticlePageParam) =>
  defHttp.get<ArticleListGetResultModel>({ url: Api.article, params }, { isPage: true });
export const deletePost = (articleId: String) =>
  defHttp.delete({
    url: Api.article + '/' + articleId,
  });
export const setPostStatus = (id: number, status: number) =>
  defHttp.put({ url: Api.article + '/' + id + '/' + status });
/**
 * 文章标签
 */
 export const addTag = (params?: TagAddParam) => defHttp.post({ url: Api.tag, params });
 export const getTagList = (params: TagPageParam) =>
 defHttp.get<TagPageListGetResultModel>({ url: Api.tag, params }, { isPage: true });
 export const editTag = (params?: TagUpdatedParam & TagAddParam) =>
 defHttp.put({ url: Api.tag, params });
 export const deleteTag = (id: String) =>
 defHttp.delete({
   url: Api.tag + '/' + id,
 });

/**
 * 文章种类
 */
 export const addCategory = (params?: CategoryAddParam) => defHttp.post({ url: Api.category, params });
 export const getCategoryList = (params: CategoryPageParam) =>
 defHttp.get<CategoryPageListGetResultModel>({ url: Api.category, params }, { isPage: true });
 export const editCategory = (params?: CategoryUpdatedParam & CategoryAddParam) =>
 defHttp.put({ url: Api.category, params });
 export const deleteCategory = (id: String) =>
 defHttp.delete({
   url: Api.category + '/' + id,
 });
/**
 * 评论
 */ 
 export const getCommentList = (params: CommentPageParam) =>
 defHttp.get<CategoryPageListGetResultModel>({ url: Api.comment, params }, { isPage: true });
 export const editComment = (params?: CommentUpdatedParam & CommentAddParam) =>
 defHttp.put({ url: Api.comment, params });
 export const deleteComment = (id: String) =>
 defHttp.delete({
   url: Api.comment + '/' + id,
 });

 /*
* 签到事件
*/
export const addSignEvent = (params?: SignEventAddParam) => defHttp.post({ url: Api.signEvent, params });
export const getSignEventList = (params: SignEventPageParam) =>
defHttp.get<SignEventPageListGetResultModel>({ url: Api.signEvent, params }, { isPage: true });
export const editSignEvent = (params?: SignEventUpdatedParam & SignEventAddParam) =>
defHttp.put({ url: Api.signEvent, params });
export const deleteSignEvent = (id: String) =>
defHttp.delete({
  url: Api.signEvent + '/' + id,
});

/*
* 签到信息
*/
export const addSignAttendance = (params?: SignAttendanceAddParam) => defHttp.post({ url: Api.signAttendance, params });
export const getSignAttendanceList = (params: SignAttendancePageParam) =>
defHttp.get<SignAttendancePageListGetResultModel>({ url: Api.signAttendance, params }, { isPage: true });
export const editSignAttendance = (params?: SignAttendanceUpdatedParam & SignAttendanceAddParam) =>
defHttp.put({ url: Api.signAttendance, params });
export const deleteSignAttendance = (id: String) =>
defHttp.delete({
  url: Api.signAttendance + '/' + id,
});

/*
* 签到积分
*/
export const addSignPoint = (params?: SignPointAddParam) => defHttp.post({ url: Api.signPoint, params });
export const getSignPointList = (params: SignPointPageParam) =>
defHttp.get<SignPointPageListGetResultModel>({ url: Api.signPoint, params }, { isPage: true });
export const editSignPoint = (params?: SignPointUpdatedParam & SignPointAddParam) =>
defHttp.put({ url: Api.signPoint, params });
export const deleteSignPoint = (id: String) =>
defHttp.delete({
  url: Api.signPoint + '/' + id,
});
